import { createSlice } from '@reduxjs/toolkit';
const cart = createSlice({
  name: 'cart',
  initialState: {
    num: 100,
  },
  reducers: {
    adda(state, actions) {
      state.num += actions.payload;

      console.log(state.num, actions);
      //     state是上面的数据 通过state.num来赋值
      //     action是传递的参数，需要使用actions.payload来获取
      //     当是数组的时候，需要进行浅拷贝
      //      const copylist =  [...state.list]
    },
  },
});
export const { adda } = cart.actions;
export default cart;
